<template>
  <div>
    <teleport v-if="isShow" to="#teleport-container">
      <div>
        <h1>Vue3Teleport</h1>
      </div>
    </teleport>

    <button @click="isShow = !isShow">点击</button>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";

const isShow = ref(false);

onMounted(() => {
  setTimeout(() => {
    isShow.value = true;
  }, 0); //确保teleport组件在寻找节点时，节点已经存在
});
</script>

<style></style>
